package com.ftg.learn.controller;

import com.ftg.learn.entity.SysRoleEntity;
import com.ftg.learn.service.SysRoleService;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 布衣
 */
@RestController
@RequestMapping("/plus")
public class SysRoleController {

    @Resource
    SysRoleService sysRoleService;

    @PostMapping("/save")
    public boolean save(@RequestBody SysRoleEntity  entity){
        return sysRoleService.save(entity);
    }

    @PostMapping("/saveBatch")
    public boolean saveBatch(@RequestBody List<SysRoleEntity> entities){
        return sysRoleService.saveBatch(entities);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody SysRoleEntity entity){
        return sysRoleService.updateById(entity);
    }

    @DeleteMapping("/delete")
    public boolean delete(@RequestParam Long id){
        return sysRoleService.removeById(id);
    }

    @GetMapping("/get")
    public SysRoleEntity get(@RequestParam Long id){
        return sysRoleService.getById(id);
    }

    @GetMapping("/list")
    public List<SysRoleEntity> list(){
        return sysRoleService.list();
    }

}
